﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DHQGHN.DAL.Models.Admin;
namespace DHQGHN.PM0.Models.Admin
{
    public class EducationTrainingModel
    {
        public string EDUCATION_TRAINING_ID { get; set; }

        [Remote("CheckExistEducationLevelName", "EducationTraining", ErrorMessage = "EducationTrainingNameExist", HttpMethod = "POST", AdditionalFields = "EDUCATION_TRAINING_ID")]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập tên trình độ đào tạo")]
        [StringLength(255, ErrorMessage = "Độ dài tối đa là 255 kí tự")]
        [Display(Name = "Tên trình độ đào tạo")]
        public string Name { get; set; }

        [Remote("CheckExistEducationTrainingCode", "EducationTraining", ErrorMessage = "EducationTrainingCodeExist", HttpMethod = "POST", AdditionalFields = "EDUCATION_TRAINING_ID")]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập mã trình độ đào tạo")]
        [Display(Name = "Mã trình độ đào tạo")]
        [StringLength(12, ErrorMessage = "Độ dài tối đa 12 kí tự")]
        [RegularExpression(@"^[a-zA-Z0-9]+[a-zA-Z0-9_]*[a-zA-Z0-9]*$", ErrorMessage = "Mã không đúng định dạng")]
        public string Code { get; set; }

        [Display(Name = "Mô tả")]
        [StringLength(1000, ErrorMessage = "độ dài tối đa là 255 ksi tự ")]
        public string Descriptions { get; set; }

        public int Deleted { get; set; }
        public int RecordCount { get; set; }
        public const string FIELD_RECORD_COUNT = "RecordCount";

        #region Field list from database
        public const string FIELD_ID = "EDUCATION_TRAINING_ID";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        #endregion

        public EducationTrainingModel()
        {
            // TODO: Complete member initialization
        }

        public EducationTrainingModel(DAL.Models.Admin.EducationTrainingModel model)
        {
            // TODO: Complete member initialization
            EDUCATION_TRAINING_ID = model.EDUCATION_TRAINING_ID;
            Code = model.Code;
            Name = model.Name;
            Descriptions = model.Descriptions;
            RecordCount = model.RecordCount;
            Deleted = model.Deleted;
        }


        internal DAL.Models.Admin.EducationTrainingModel toDALModel()
        {
            DAL.Models.Admin.EducationTrainingModel model = new DAL.Models.Admin.EducationTrainingModel
            {
                EDUCATION_TRAINING_ID = EDUCATION_TRAINING_ID,
                Code = Code,
                Name = Name,
                Descriptions = Descriptions,
                RecordCount = RecordCount,
                Deleted=Deleted
            };
            return model;
        }
    }
}